package com.gopay.cashier.service.impl;

import com.gopay.cashier.service.B2BBankConfigService;
import com.gopay.common.Result;
import com.gopay.common.domain.bis.BisEbankB2BConfig;
import com.gopay.remote.bank.BisB2bConfigRemoteService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 获取bis B2B银行配置
 * Created by Administrator on 14-8-20.
 */
@Service("b2bBankConfigService")
public class B2BBankConfigServiceImpl implements B2BBankConfigService {


    @Autowired
    private BisB2bConfigRemoteService bisB2BBankConfig;

    public String getB2BConfig(String b2bBankCode){
        Result result = bisB2BBankConfig.findBisEbankB2BConfigByBank(b2bBankCode);
        BisEbankB2BConfig bisEbankB2BConfig = (BisEbankB2BConfig)result.getDefaultModel();
        if(bisEbankB2BConfig != null && bisEbankB2BConfig.isSpecial()){
            String name =  bisEbankB2BConfig.getSpecialCode();
            return StringUtils.isBlank(name) == true ? null : name;
        }
        return null;
    }
}
